<?php
/**
 * @brief join_check_refer protocol
 *
 * @param post uid User Id
 * @param post refer Friend Refer
 * @return True/False
 * @author con100 <con100@playplus.net>
 * @since 05/04/2013
 * @copyright Copyright (c) 2013, PlayPlus
 **/
include 'dbconn.php';

$user_id = mysql_real_escape_string($_POST['uid']);
$r_code = mysql_real_escape_string($_POST['refer']);
$time = time();

$sql = "select id, my_refer from ebs_member where my_refer='$r_code'";
$res = mysql_query($sql);
$num_refer = mysql_fetch_assoc($res);
if ($num_refer['id']) {
	$sql = "update ebs_member set fr_refer = '$r_code' where id = '$user_id'";
	$res = mysql_query($sql);
/*	$sql1 = "insert into ebs_refer (id, refer_id, refer_time, refer_reward) values ('$user_id', '$num_refer[id]', '$time', 'null') ";
	$res1 = mysql_query($sql1);
*/
	$result = array("Result"=>TRUE);
}
else{
	$result = array("Result"=>FALSE);
}
echo json_encode($result);
/*
header('Content-type: text/xml; charset=UTF-8');

$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString('  ');
$writer->startDocument('1.0', 'UTF-8');

$writer->startElement('join_check_refer');
	$writer->startElement('result');
	$writer->text($result);
	$writer->endElement();
	if($result == "TRUE"){
		$writer->startElement('time');
		$writer->text($time);
		$writer->endElement();
	}
$writer->endElement();

echo($writer->outputMemory());
*/
?>